package cn.feng.thinkInJava.a8_2_字符串.strings.a13_07_00;

//: strings/SimpleRead.java
import java.io.*;

/**
 * 扫描输入
 * 
 * @author fengyu
 * @date 2015年8月8日
 */
public class SimpleRead
{
	public static BufferedReader input=new BufferedReader(new StringReader("Sir Robin of Camelot\n22 1.61803"));
	
	public static void main(String[] args)
	{
		try
		{
			System.out.println("What is your name?");
			//读取一行文本
			String name=input.readLine();
			System.out.println(name);
			System.out.println("How old are you? What is your favorite double?");
			System.out.println("(input: <age> <double>)");
			String numbers=input.readLine();
			System.out.println(numbers);
			String[] numArray=numbers.split(" ");
			int age=Integer.parseInt(numArray[0]);
			double favorite=Double.parseDouble(numArray[1]);
			System.out.format("Hi %s.\n",name);
			System.out.format("In 5 years you will be %d.\n",age+5);
			System.out.format("My favorite double is %f.",favorite/2);
		}
		catch(IOException e)
		{
			System.err.println("I/O exception");
		}
	}
} /* Output:
What is your name?
Sir Robin of Camelot
How old are you? What is your favorite double?
(input: <age> <double>)
22 1.61803
Hi Sir Robin of Camelot.
In 5 years you will be 27.
My favorite double is 0.809015.
*///:~
